function [criterion] = HPZ_Criterion_Extreme_Param(single_param,observations,treatment,function_flag,zeros_flag,metric_flag,asymmetric_flag)
global numeric_flag

% The function calculates the NLLS criterion (similar to CFGK (2007)) for 
% a given specification of a utility function and a set of choices. 
% param is a vector of two parameters - beta (the disappointment aversion
% parameter) and the utility function parameter (rho for CRRA and A for
% CARA).
% observations is a matrix with obs_num rows and 4 columns.
% each row is one choice of the subject.
% The first column is the quantity of good 1 chosen by the subject.
% The second column is the quantity of good 2 chosen by the subject.
% The third column is the price of good 1. 
% The fourth column is the price of good 2. 
% treatment is the number of treatment in CFGK (2007).
%
% The function returns the value of the criterion for the specified
% functional form and the given data. 

%% "True" value of this boolean flag restricts beta to be equal to zero
global beta_zero_flag
%% "True" value of this boolean flag restricts rho to be equal to zero
global rho_zero_flag

    if beta_zero_flag == true
        % if beta is restricted to be 0, then:

        % initialize the parameter vector
        param = zeros(1,2);

        % set beta to be equal to 0, and rho as it is
        param(2)=single_param;

    elseif rho_zero_flag == true
        % if rho is restricted to be 0, then:

        % initialize the parameter vector
        param = zeros(1,2);

        % set rho to be equal to 0, and beta as it is
        param(1)=single_param;


    end

    % number of obsevations
    obs_num = length(observations(:,1));
    
    if numeric_flag == true
        % The endowments are normalized to 1
        endowments=ones(obs_num,1);
        % Find optimal choices given prices and parameters
        optimal_choice_zeros=HPZ_Choices(observations(:,3:4),endowments,treatment,function_flag,asymmetric_flag,param);

    else
        optimal_choice_zeros=HPZ_Choices_Analytical(observations,param,function_flag);
    end
    
    if (zeros_flag==2)
        % remove zeros using Choi et al. (2007) correction
        optimal_choice = HPZ_No_Corners (optimal_choice_zeros,obs_num,1);
        
    else
        
        optimal_choice = optimal_choice_zeros;
        
    end
    
    if (metric_flag==2)
        % Compute NLLS criterion using Choic et al. (2007) metric
        criterion = HPZ_ldr_Criterion(observations,optimal_choice);
        
    else
        % Compute NLLS criterion using Euclidean metric
        criterion = HPZ_Euclid_Criterion(observations,optimal_choice);
        
    end
end